<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<script type="text/javascript">
		function buttonClick(){
			var value = document.getElementById("myId").value;
			yuan(value);
		}
		//字符串0120   0240
		function yuan(x) {
			if(!x || x.length!=4){
				alert("参数错误 ");
				return;
			}
			debugger;
			var month = parseInt(x.substring(0,2));
			var day = parseInt(x.substring(2,4));
			if(month==2){
// 				var x = 0120; i <= 0218; 
				if(day>0 && day<=18){
					alert("水瓶座")
				}else if(day>18 && day<=28){
					alert("双鱼座")
				}else{
					alert("日期错误")
				}
			}else if(month==3){
				if(day>0 && day<=20){
					alert("双鱼座")
				}else if(day>20 && day<=31){
					alert("白羊座")
				}else{
					alert("日期错误")
				}
			}else if(month==4){
				if(day>0 && day<=19){
					alert("白羊座");
				}else if(day>19 && day<=30){
					alert("金牛座");
				}else{
					alert("日期错误");
				}
			}else if(month==5){
				if(day>0 && day<=20){
					alert("金牛座");
				}else if(day>20 && day<=31){
					alert("双子座");
				}else{
					alert("日期错误");
				}
			}else if(month==6){
				if(day>0 && day<=21){
					alert("双子座");
				}else if(day>21 && day<30){
					alert("巨蟹座");
				}else{
					alert("日期错误");
				}
			}else if(month==7){
				if(day>0 && day<=22){
					alert("巨蟹座");
				}else if(day>22 && day<=31){
					alert("狮子座");
				}else{
					alert("日期错误");
				}
			}else if(month==8){
				if(day>0 && day<=22){
					alert("狮子座");
				}else if(day>23 && day<=31){
					alert("处女座");
				}else{
					alert("日期错误");
				}
			}else if(month==9){
				if(day>0 && day<=22){
					alert("处女座");
				}else if(day>22 && day<=30){
					alert("天平座");
				}else{
					alert("日期错误");
				}
			}else if(month==10){
			    if(day>0 && day<=23){
			    	alert("天平座");
			   }else if(day>23 && day<31){
				   alert("天蝎座");
			   }else{
				   alert("日期错误");
			   }
			}else if(month==11){
				if(day>0 && day<=22){
					alert("天蝎座");
				}else if(day>22 && day<=30){
					alert("射手座");
				}else{
					alert("日期错误");
				}
			}else if(month==12){
				if(day>0 && day<=21){
					alert("射手座");
				}else if(day>22 && day<=31){
					alert("魔蝎座");
				}else{
					alert("日期错误");
				}
			}else if(month==1){
				if(day>0 && day<=19){
					alert("魔蝎座");
				}else if(day>19 && day<=31){
					alert("水瓶座");
				}else{
					alert("日期错误");
				}
			}
			
		}
	</script>
	<input name="name" id="myId">
	<input name="myButton" id="myButton" type="button" value="计算星座"
		onclick="buttonClick()">
</body>
</html>